/**
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
package mobcam;

import java.io.IOException;
import javax.microedition.media.*;
import javax.microedition.media.control.*;


/**
 *
 * @author kms
 */
public class CameraController {
    private VideoControl mVideoControl;
    private Player mPlayer;

    public String getCapabilities(){
        String supports = "Supporting: "+System.getProperty("video.snapshot.encodings");
        return supports;
    }

    byte[] getSnapshot() throws IOException, MediaException{
        mPlayer = Manager.createPlayer("capture://video");
        mPlayer.realize();
        mVideoControl = (VideoControl)mPlayer.getControl("VideoControl");
        mVideoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, null);
        mPlayer.start();
        byte[] image = mVideoControl.getSnapshot("encoding=jpeg&width=480&height=640");
        mPlayer.close();
        mVideoControl = null;
        mPlayer = null;
        return image;
    }
    

}
